package com.huya.mapper;

import com.huya.pojo.entity.TestQuestion;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TestQuestionMapper {
    /**
     * 根据测试id获取测试题目列表
     * @param testId
     * @return
     */
    @Select("SELECT * FROM test_questions WHERE test_id = #{testId}")
    List<TestQuestion> getQuestionByTestId(Long testId);

    /**
     * 根据题目id获取选项
     * @param questionId
     * @return
     */
    @Select("SELECT options FROM test_questions WHERE question_id = #{questionId}")
    String findOptionsById(Long questionId);

    /**
     * 批量插入测试题目
     * @param testQuestions
     */
    void insertList(List<TestQuestion> testQuestions);

    /**
     * 根据测试id删除测试题目
     * @param testId
     */
    @Select("DELETE FROM test_questions WHERE test_id = #{testId}")
    void deleteByTestId(Long testId);
}
